package elec;

import static mathUtils.VecMath.*;
import java.util.ArrayList;

import forces.FieldForce;

public class ElectricForce implements FieldForce {

	public float constant = 1.0f;
	public ArrayList<Electric> objectList;

	public ElectricForce() {this(1f);}
	public ElectricForce(float k) {
		objectList = new ArrayList<Electric>();
		constant = k;
	}
	public ElectricForce(float k, int d) {
		this(k);
	}
	
	public void applyForces() {
		for (int i = 1; i < objectList.size(); ++i) {
			Electric a = objectList.get(i);
			for (int j = 0; j < i; ++j) {
				Electric b = objectList.get(j);
				float f[] = b.eForceOn(a, constant);
				a.takeForce(f);
				vecScale(f, -1);
				b.takeForce(f);
			}
		}
	}

}
